package com.xx.servlte;

import com.xx.entity.Auction;
import com.xx.service.AuctionService;
import com.xx.service.Impl.AuctionServiceImpl;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

@WebServlet(name = "UpdateServlet",urlPatterns = "/UpdateServlet")
public class UpdateServlet extends HttpServlet {
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        doGet(request, response);
    }

    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        //获取请求数据
        response.setCharacterEncoding("utf-8");
        response.setContentType("text/html; charset=utf-8");
        Integer auctionId=Integer.valueOf(request.getParameter("id"));
        String auctionName=request.getParameter("auctionName");//名称
        String auctionStartPrice=request.getParameter("auctionStartPrice");//起拍价
        String auctionUpset=request.getParameter("auctionUpset");//底价
        String auctionStartTime=request.getParameter("auctionStartTime");//开始时间
//        String auctionEndTime=request.getParameter("auctionEndTime");//结束时间
        String auctionDesc=request.getParameter("auctionDesc");//描述

        Auction auction=new Auction(auctionId,auctionName,auctionStartPrice,auctionUpset,auctionStartTime,null,null,null,auctionDesc);
        AuctionService dao=new AuctionServiceImpl();
        dao.update(auction);
        response.sendRedirect("AuctionServlet?action=selectGetAll");
    }
}
